import { createRouter, createWebHashHistory } from 'vue-router';

import Layout from '@/layout/Index.vue';
import BlankLayout from '@/layout/BlankLayout.vue';
// : Array<RouteRecordRaw>
export const routes = [
	{
		path: '/',
		component: Layout,
		redirect: 'home',
		children: [
			{
				// 首页
				path: 'home',
				component: () => import('@/views/Home.vue'),
				name: 'Home',
				meta: {
					title: '首页',
					icon: 'el-icon-s-home'
				}
			},
			{
				// 仪表盘
				path: 'dashboard',
				component: () => import('@/views/Dashboard.vue'),
				name: 'Dashboard',
				meta: {
					title: '统计分析',
					icon: 'el-icon-s-help'
				}
			},
			{
				// 热门商品统计
				path: 'item',
				component: BlankLayout,
				// component: { render (h: any) { return h('router-view'); } },
				name: 'Item',
				redirect: 'table',
				meta: {
					title: '商品统计',
					icon: 'el-icon-s-shop'
				},
				children: [
					{
						path: 'hot-items',
						component: () => import('@/views/HotItems.vue'),
						name: 'HotItems',
						meta: { title: '热门商品' }
					}
				]
			},
			{
				// 热门页面分析、PV、UV
				path: 'page',
				component: BlankLayout,
				// component: { render (h: any) { return h('router-view'); } },
				name: 'Page',
				redirect: 'table',
				meta: {
					title: '页面统计',
					icon: 'el-icon-s-operation'
				},
				children: [
					{
						path: 'hot-pages',
						component: () => import('@/views/HotPages.vue'),
						name: 'HotPages',
						meta: { title: '热门页面' }
					},
					{
						path: 'pv',
						component: () => import('@/views/PV.vue'),
						name: 'PV',
						meta: { title: 'PV统计' }
					},
					{
						path: 'set-uv',
						component: () => import('@/views/SetUV.vue'),
						name: 'SetUV',
						meta: { title: 'SetUV统计' }
					},
					{
						path: 'bloom-uv',
						component: () => import('@/views/BloomUV.vue'),
						name: 'BloomUV',
						meta: { title: 'BloomUV统计' }
					}
				]
			},
			{
				// 市场推广、广告数据
				path: 'marketing',
				component: BlankLayout,
				// component: { render (h: any) { return h('router-view'); } },
				name: 'Marketing',
				redirect: 'table',
				meta: {
					title: '营销统计',
					icon: 'el-icon-s-marketing'
				},
				children: [
					{
						path: 'channel-marketing',
						component: () => import('@/views/ChannelMarketing.vue'),
						name: 'ChannelMarketing',
						meta: { title: '市场推广统计' }
					},
					{
						path: 'advertising',
						component: () => import('@/views/Advertising.vue'),
						name: 'Advertising',
						meta: { title: '广告数据统计' }
					}
				]
			},
			{
				// 恶意登录检测
				path: 'detect',
				component: BlankLayout,
				// component: { render (h: any) { return h('router-view'); } },
				name: 'Detect',
				redirect: 'table',
				meta: {
					title: '系统监控',
					icon: 'el-icon-s-platform'
				},
				children: [
					{
						path: 'login-fail',
						component: () => import('@/views/LoginFail.vue'),
						name: 'LoginFail',
						meta: { title: '恶意登录检测' }
					}
				]
			},
			{
				// 图表展示
				path: 'charts',
				component: BlankLayout,
				// component: { render (h: any) { return h('router-view'); } },
				name: 'Charts',
				redirect: 'table',
				meta: {
					title: '图表展示',
					icon: 'el-icon-data-analysis'
				},
				children: [
					{
						path: 'charts',
						component: () => import('@/views/Charts.vue'),
						name: 'Charts',
						meta: { title: '图表展示' }
					}
				]
			}
		]
	},
	{
		// 登录
		path: '/login',
		name: 'Login',
		hidden: true,
		component: () => import('@/views/Login.vue')
	}
];

const router = createRouter({
	history: createWebHashHistory(process.env.BASE_URL),
	routes
});

export default router;
